#pragma once
#include <GL/glew.h>
#include <string>
#include <iostream>
#include <fstream>
#include <sstream>
#include <unordered_map>
#include "ErrorDetect.h"
#include "glm/glm.hpp"

struct ShaderProgramSource
{
	std::string VertexSource;
	std::string FragmentSource;
};

class Shader
{
private:
	std::unordered_map<std::string, int> location_cache;
	unsigned int m_RendererID;
	const std::string& m_FilePath;
public:
	Shader(const std::string &filePath);
	~Shader();

	void Bind()const;
	void Unbind() const;
	void SetUniformMat4f(const std::string& name, const glm::mat4& matrix);
	void SetUniform4f(const std::string& name, float v0, float v1, float v2, float v3);
	void SetUniform1i(const std::string& name, int value);
private:
	static unsigned int CompileShader(unsigned int type, const std::string& source);
	static ShaderProgramSource ParseShader(const std::string& filePath);
	static unsigned int CreateShader(const std::string& verexShader, const std::string& fragmentShader);
	int GetUniformLocation(const std::string& name);
};

